Use StaticFileHandler when files are local#2656
Merged
gnestor merged 4 commits intojupyter:masterfrom Jul 19, 2017
Merged
Conversation
takluyver
reviewed
Jul 18, 2017
|
|
||
| r = self.request('GET', 'files/test.txt') | ||
| self.assertEqual(r.status_code, 200) | ||
| self.assertEqual(r.headers['content-type'], 'text/plain; charset=UTF-8') |
Member
Contributor
There was a problem hiding this comment.
It looks like the tests are passing on Travis... It looks good to me. What says @minrk?
Member
There was a problem hiding this comment.
We can define AuthenticatedFileHandler.get_content_type to include the charset.
Member
There was a problem hiding this comment.
Are you requesting that @agermanidis does that in this PR, or suggesting that we do it separately?
Contributor
Author
|
Thanks, I wasn't aware of |
Member
Contributor
|
Thanks @agermanidis!! We appreciate your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the set of changes described at #968, and fixes #1024.
In summary, a
files_handler_classis added as an attribute toContentsManager, specifying a custom request handler for the/filesrequests. ForFileContentsManager, this is set toAuthenticatedFilesHandler(which is a light proxy over Tornado'sStaticFileHandler).Using tornado's
StaticFileHandlerclass for serving local files is more efficient and enables HTTP Range requests, which are necessary for seekable video embeds (see #1024).An additional change is made to the
test_contents_managertest case to allow bothtext/plainand
text/plain; charset=UTF-8as acceptablecontent-types. The reason being that whileFilesHandlerexplicitly specifies the content type (here), Tornado's static file handler just sets the content type to the mime-type of the file, which doesn't include charset; overwriting that would be awkward.This is my first time digging through this codebase so any changes/comments/suggestions would be much appreciated.